home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / AppsToGo / DTS.Lib / DTS.Lib.headers / Utilities.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  60.6 KB  |  1,800 lines  |  [TEXT/MPS ]

  1. /*-----------------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    Collection of Utilities for DTS Sample code
  6. #
  7. #    Program:    Utilities.c.o
  8. #    File:        Utilities.h    -    Header for C Source
  9. #
  10. #    Copyright © 1988-1990 Apple Computer, Inc.
  11. #    All rights reserved.
  12. #
  13. -----------------------------------------------------------------------------------------*/
  14.  
  15. #ifndef __UTILITIES__
  16. #define __UTILITIES__
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21.  
  22. #ifndef __QUICKDRAW__
  23. #include <QuickDraw.h>
  24. #endif
  25.  
  26. #ifndef __DIALOGS__
  27. #include <Dialogs.h>
  28. #endif
  29.  
  30. #ifndef __FILES__
  31. #include <Files.h>
  32. #endif
  33.  
  34. #ifndef __MEMORY__
  35. #include <Memory.h>
  36. #endif
  37.  
  38. #ifndef __MENUS__
  39. #include <Menus.h>
  40. #endif
  41.  
  42. #ifndef __OSUTILS__
  43. #include <OSUtils.h>
  44. #endif
  45.  
  46. #ifndef __WINDOWS__
  47. #include <Windows.h>
  48. #endif
  49.  
  50. #include "UtilitiesCommon.h"
  51.  
  52. #ifndef __STRINGUTILS__
  53. #include "StringUtils.h"
  54. #endif
  55.  
  56.  
  57. #ifdef powerc
  58. #pragma options align=mac68k
  59. #endif
  60. struct PopupCtlData {
  61.     MenuHandle        mHandle;
  62.     short            mID;
  63.     char            mPrivate[1];
  64. };
  65. typedef struct PopupCtlData PopupCtlData;
  66. typedef PopupCtlData *PopupCtlDataPtr, **PopupCtlDataHandle;
  67. #ifdef powerc
  68. #pragma options align=reset
  69. #endif
  70.  
  71. #define    kMenuItemTxtInsert    -1
  72. #define    kMenuItemNumInsert    -2
  73. #define kMenuItemSectionEnd    -3
  74.  
  75. /*-----------------------------------------------------------------------------------------
  76.     Global constants
  77. -----------------------------------------------------------------------------------------*/
  78. #ifndef applec
  79.  
  80. #ifndef nil
  81. #define nil    0L
  82. #endif
  83.  
  84. #ifndef _WaitNextEvent
  85. #define _WaitNextEvent    0xA860
  86. #endif
  87.  
  88. #ifndef _InitGraf
  89. #define _InitGraf        0xA86E
  90. #endif
  91.  
  92. #ifndef _Unimplemented
  93. #define _Unimplemented    0xA89F
  94. #endif
  95.  
  96. /*
  97. #define screenActive            15
  98. */
  99. #endif
  100.  
  101. #define    kNoEvents                0            /* no events mask */
  102. #define kDelayTime                4            /* For the delay time when flashing the
  103.                                                menubar and highlighting a button.
  104.                                                4/60ths of a second*/
  105.  
  106. #define kStartPtH                2            /* offset from the left of the screen */
  107. #define kStartPtV                2            /* offset from the top of the screen */
  108. #define kStaggerH                12            /* staggering amounts for new windows */
  109. #define kStaggerV                16
  110.  
  111. #define chHome                    '\001'        /* ASCII code for the Home key */
  112. #define chEnter                    '\003'        /* ASCII code for Enter character */
  113. #define chEnd                    '\004'        /* ASCII code for the End key */
  114. #define chHelp                    '\005'        /* ASCII code for Help key */
  115. #define chBackspace                '\010'        /* ASCII code for Backspace character */
  116. #define chTab                    '\011'        /* ASCII code for Tab character */
  117. #define chPageUp                '\013'        /* ASCII code for Page Up key */
  118. #define chPageDown                '\014'        /* ASCII code for Page Down key */
  119. #define chReturn                '\015'        /* ASCII code for Return character */
  120. #define chFunction                '\020'        /* ASCII code for any function key */
  121. #define chClear                    '\033'        /* ASCII code for Clear key (aka ESC) */
  122. #define chEscape                '\033'        /* ASCII code for Escape (aka Clear) key */
  123. #define chLeft                    '\034'        /* ASCII code for left arrow */
  124. #define chRight                    '\035'        /* ASCII code for right arrow */
  125. #define chUp                    '\036'        /* ASCII code for up arrow */
  126. #define chDown                    '\037'        /* ASCII code for down arrow */
  127. #define chFwdDelete                '\177'        /* ASCII code for forward delete */
  128. #define chSpace                    ' '            /* ASCII code for Space character */
  129.  
  130. enum { kQDOriginal = 0, kQD8Bit, kQD32Bit };    /* For use with gQDVersion */
  131.  
  132. /*-----------------------------------------------------------------------------------------
  133.     Types
  134. -----------------------------------------------------------------------------------------*/
  135.  
  136. #ifdef powerc
  137. #pragma options align=mac68k
  138. #endif
  139. struct    WindowTemplate    {                    /*template to a WIND resource*/
  140.     Rect    boundsRect;
  141.     short    procID;
  142.     Boolean    visible;
  143.     Boolean    filler1;
  144.     Boolean    goAwayFlag;
  145.     Boolean    filler2;
  146.     long    refCon;
  147.     Str255    title;
  148. };
  149. typedef    struct    WindowTemplate    WindowTemplate;
  150. typedef            WindowTemplate    *WindowTPtr, **WindowTHndl;
  151. #ifdef powerc
  152. #pragma options align=reset
  153. #endif
  154.  
  155.  
  156. #ifdef powerc
  157. #define FlushInstructionCache()
  158. #endif
  159.  
  160. typedef Rect    (*PositionWndProcPtr)(WindowPtr window, WindowPtr relatedWindow, Rect sizeInfo);
  161. typedef void    (*DrawControlProcPtr)(ControlHandle ctl);
  162. typedef short    (*GetButtonVariantProcPtr)(ControlHandle ctl, Boolean *stop);
  163.  
  164.  
  165. #ifdef powerc
  166. #pragma options align=mac68k
  167. #endif
  168. typedef struct PFSSpec {
  169.     FSSpec    fss;
  170.     Str31    volName;
  171. } PFSSpec;
  172. typedef PFSSpec *PFSSpecPtr;
  173. #ifdef powerc
  174. #pragma options align=reset
  175. #endif
  176.  
  177. typedef Boolean    (*TrackControlProcPtr)(ControlHandle ctl, short part, EventRecord *event);
  178. typedef void    (*ScrollProcPtr)(ControlHandle ctl, short part, short oldVal, short newVal);
  179. typedef struct ControlStyleInfo {
  180.     short                ctlID;
  181.     TrackControlProcPtr    trackProc;
  182.     ScrollProcPtr        scrollProc;
  183.     short                hArrowVal;
  184.     short                vArrowVal;
  185.     short                hPageVal;
  186.     short                vPageVal;
  187.     DrawControlProcPtr    drawControl;
  188.     short                fontSize;
  189.     Style                fontStyle;
  190.     Str32                font;
  191.     Str63                keyEquivs;
  192.     Str255                balloonHelp;
  193. } ControlStyleInfo;
  194. typedef ControlStyleInfo *ControlStyleInfoPtr;
  195.  
  196.  
  197.  
  198. /*-----------------------------------------------------------------------------------------
  199.     Handy Macros/inlines
  200. -----------------------------------------------------------------------------------------*/
  201. #ifdef false                                        /* The c++ stuff is turned OFF!!! */
  202.  
  203. inline Point* TopLeft(Rect& r)                        /* provide access to rect.topLeft  */
  204. {    return (Point*)(&r.top); }
  205.  
  206. inline Point* BotRight(Rect& r)                        /* provide access to rect.botRight  */
  207. {    return (Point*)(&r.bottom); }
  208.  
  209. inline short HiWrd(long aLong)                        /* return the hi word of a long */
  210. {    return ((aLong >> 16) & 0xFFFF); }
  211.  
  212. inline short LoWrd(long aLong)                        /* return the lo word of a long */
  213. {    return (aLong & 0xFFFF); }
  214.  
  215. inline void SETPT(Point *pt,short h,short v)
  216. {    (*pt).h = h; (*pt).v = v); }
  217.  
  218. inline void SETRECT(Rect *r,short left,short top,short right,short bottom)
  219. {    SETPT(TopLeft(*r), left, top); SETPT(BotRight(*r), right, bottom); }
  220.  
  221. /* 
  222.  *    Useful functions for testing gestalt attribute responses
  223.  *
  224.  *    BTstBool returns a true boolean value (0 or 1), but is slower than:
  225.  *    BTstQ which simply returns a non-zero value if the bit is set which
  226.  *    means the result could get lost if assigned to a short, for example.
  227.  *
  228.  *    arg is any integer value, bitnbr is the number of the bit to be tested.
  229.  *    bitnbr = 0 is the least significant bit.
  230.  */
  231. inline short BTstBool(arg, bitnbr)    
  232. {    return ((arg >> bitnbr) & 1); }
  233.  
  234. inline long BTstQ(arg, bitnbr)
  235. {    return (arg & (1 << bitnbr)); }
  236.  
  237. #else
  238.  
  239.  
  240. #ifndef THINK_C
  241. #define QD(whatever) (qd.##whatever)
  242. #else
  243. #define QD(whatever) (whatever)
  244. #endif
  245.  
  246.  
  247. #define TopLeft(r)        (* (Point *) &(r).top)
  248. #define BotRight(r)        (* (Point *) &(r).bottom)
  249. #define HiWrd(aLong)    (((aLong) >> 16) & 0xFFFF)
  250. #define LoWrd(aLong)    ((aLong) & 0xFFFF)
  251. #define MIN(a, b) ((a) < (b) ? (a) : (b) )
  252. #define MAX(a, b) ((a) > (b) ? (a) : (b) )
  253. #define SETPT(pt, x, y)    (*(pt)).h = (x); (*(pt)).v = (y)
  254. #define SETRECT(r, left, top, right, bottom)    \
  255.                         SETPT(&TopLeft(*(r)), (left), (top)); \
  256.                         SETPT(&BotRight(*(r)), (right), (bottom))
  257.  
  258. #define offsetof(structure,field) ((unsigned long)&((structure *) 0)->field)
  259.  
  260. /* 
  261.  *    Useful macros for testing gestalt attribute responses
  262.  *
  263.  *    BTstBool returns a true boolean value (0 or 1), but is slower than:
  264.  *    BTstQ which simply returns a non-zero value if the bit is set which
  265.  *    means the result could get lost if assigned to a short, for example.
  266.  *
  267.  *    arg is any integer value, bitnbr is the number of the bit to be tested.
  268.  *    bitnbr = 0 is the least significant bit.
  269.  */
  270. #define BTstBool(arg, bitnbr)    ((arg >> bitnbr) & 1)
  271. #define BTstQ(arg, bitnbr)        (arg & (1 << bitnbr))
  272.  
  273. #endif
  274.  
  275. /*-----------------------------------------------------------------------------------------
  276.     Global variables
  277. -----------------------------------------------------------------------------------------*/
  278. /*    The following global variables are initialized by StardardInitialization to
  279.  *    define the environnment.  This used to be a single SysEnvRec, but now,
  280.  *    all those variables defined in a SysEnvRec can be returned by Gestalt
  281.  *    (except sysVRefNum; see FindSysFolder).  Note that all the variables
  282.  *    below will be correctly initialized whether Gestalt is available or not;
  283.  *    the Gestalt glue handles this.
  284.  */
  285.  
  286. extern ModalFilterUPP    gAlertFilterUPP;
  287. extern ModalFilterUPP    gKeyEquivFilterUPP;
  288.  
  289. extern short            gMachineType;            /* which machine this is */
  290. extern short            gSystemVersion;            /* System version number */
  291. extern short            gProcessorType;            /* which CPU this is */
  292. extern Boolean            gHasFPU;                /* true if machine has an FPU */
  293. extern short            gQDVersion;                /* major QD version #; 0 for original, 
  294.                                                     1 for color QD, 2 for 32-bit QD */
  295. extern short            gKeyboardType;            /* which type of keyboard is present */
  296. extern short            gAppleTalkVersion;        /* AppleTalk version number */
  297.         
  298. /*    These are also handled by Gestalt. gHasPMMU has no corresponding SysEnvRec
  299.  *    field, but it is handled by the glue, so we include it here for completeness.
  300.  *    gAUXVersion will be initialized with Gestalt if present, but correctly
  301.  *    set even if Gestalt is not available
  302.  */
  303. extern Boolean            gHasPMMU;                /* true if machine has a PMMU or equivalent */
  304. extern short            gAUXVersion;            /* major A/UX version number (0 if not present) */
  305.  
  306. /*    
  307.  *    gHasWaitNextEvent is set to TRUE if the Macintosh we are running on has
  308.  *    WaitNextEvent implemented. We can use this in our main event loop to
  309.  *    determine whether to call WaitNextEvent or GetNextEvent.
  310.  */
  311. extern Boolean            gHasWaitNextEvent;
  312.  
  313. /*
  314.  *    gAppResRef is the application’s resource file reference. I need to save
  315.  *    this since I can open other resource files. The current resource file is
  316.  *    always gAppResRef unless I momentarily set it to another file to read its
  317.  *    resources, and then immediately restore it back.
  318.  */
  319. extern short            gAppResRef;
  320.  
  321. /*
  322.  *    gInBackground is maintained by our osEvent handling routines. Any part of
  323.  *    the program can check it to find out if it is currently in the background.
  324.  */
  325. extern Boolean            gInBackground;            /* maintained by StandardInitialization
  326.                                                       and DoEvent */
  327.                                                       
  328. /*
  329.  *    gAppName holds the name of the application that's running. You can use if
  330.  *    for any purpose you'd like. It is also used by StandardAbout if it can't
  331.  *    find a string to use for the application name in a resource, so make sure
  332.  *    you call InitForStandardAbout if you are going to call StandardAbout. If you
  333.  *    call StandardInitialization, this is done for you.
  334.  */
  335. extern Str255            gAppName;
  336.  
  337. /*
  338.  *    gSignature holds the creator signature for the running application. It follows the
  339.  *    same rules as those for gAppName.
  340.  */
  341. extern OSType            gSignature;
  342.  
  343. /*
  344.  *    Initial values of these global variables are set to zero or FALSE by MPW's 
  345.  *    runtime initialization routines.  If the Utilities initialization routines
  346.  *    have been properly called, then gUtilitiesInited will be true.  If it is
  347.  *    not true, then the values of the above global variables are invalid.
  348.  */
  349. extern Boolean            gUtilitiesInited;
  350.  
  351. /*
  352.  *    These are global UniversalProcPtrs for AlertFilter() and KeyEquivFilter()
  353.  *    These are always initialized.
  354.  */
  355. extern ModalFilterUPP    gAlertFilterUPP;
  356. extern ModalFilterUPP    gKeyEquivFilterUPP;
  357.  
  358. extern GetButtonVariantProcPtr    gGetButtonVariant;
  359. /*
  360.  *    Use this global to add to or override the GetButtonVariant function.  There there
  361.  *    are other controls that you would like to automatically behave like check boxes
  362.  *    and radio buttons, write a function that returns the correct variant, given the
  363.  *    control, and then set this global procPtr to it.
  364.  */
  365.  
  366. /*-----------------------------------------------------------------------------------------
  367.     Interface to routines
  368. -----------------------------------------------------------------------------------------*/
  369.  
  370. #ifdef __cplusplus
  371. extern "C" {
  372. #endif
  373.  
  374. Rect        SetWindowPlacementRect(Rect *rct);
  375. /*
  376.     ¶ Overrides normal window positioning in favor of the rect passed in.
  377.  
  378.     INPUT:    rct        Pointer to rect to be used for custom window placement.
  379.     OUTPUT:    Rect    The old window placement rect.
  380.  
  381.     Set the window placement rect.  This rect overrides normal window positioning in favor of the
  382.     rect passed in.  For reference, the function also returns the old window placement rect.  If nil
  383.     is passed in for the new rect, then no change to the positioning rect is made.  The old rect is
  384.     still returned.
  385. */
  386.  
  387.  
  388.  
  389. short        CenteredAlert(short alertID, WindowPtr relatedWindow, ModalFilterUPP filter);
  390. /*
  391.     ¶ Center the alert on the same device as the related window.
  392.  
  393.     INPUT:    alertID                Resource ID of alert.
  394.             relatedWindow        Window to "follow" when determining which monitor or the alert.
  395.             filter                The alert filter.
  396.  
  397.     Given an Alert ID and a related window pointer, this routine will center the alert on the same
  398.     device as the related window.  If the related window pointer is nil, then the alert will be
  399.     centered on the device that the alert would normally be placed if Alert was called directly.
  400. */
  401.  
  402.  
  403.  
  404. void        CenterRectInRect(Rect outerRect, Rect *innerRect);
  405. /*
  406.     ¶ Given two rectangles, this routine centers the second one within the first.
  407.  
  408.     INPUT:    outerRect        The rect to center within.
  409.     IN/OUT:    innerRect        Input:    The rect to center.
  410.                             Output:    The centered rect.
  411.  
  412.     Given two rectangles, this routine centers the second one within the first.
  413. */
  414.  
  415.  
  416.  
  417. Rect        CenterWindow(WindowPtr window, WindowPtr relatedWindow, Rect sizeInfo);
  418. /*
  419.     ¶ Center the window on the same device as the related window.
  420.  
  421.     INPUT:    window                Window to center.
  422.             relatedWindow        Window to "follow" when centering.
  423.             sizeInfo            Min and max sizes for the window.
  424.                                 sizeInfo.top    = Minimum height of window.
  425.                                 sizeInfo.left   = Minimum width of window.
  426.                                 sizeInfo.bottom = Maximum height of window.
  427.                                 sizeInfo.right  = Maximum width of window.
  428.                                     If any of the above sizeInfo fields are 0, then that field
  429.                                     has no effect on limiting the change.
  430.  
  431.     Given a window pointer and a related window pointer, this routine will center the window on the
  432.     same device as the related window.  If the related window pointer is nil, then the window will be
  433.     centered on the device that the window already is.
  434.  
  435.     WARNING: This routine may move or purge memory.
  436. */
  437.  
  438.  
  439.  
  440. void        CloseAnyWindow(WindowPtr window);
  441. /*
  442.     ¶ Closes the indicated window.  Also handles if the window is a DA window.
  443.  
  444.     INPUT:    window        The window to close.
  445.  
  446.     Closes the indicated window.  Does the right thing, taking into account that the window may
  447.     belong to a DA.
  448.  
  449.     WARNING: An application window is closed via a CloseWindow call.  Use this call when you want
  450.              to keep the storage for the window record.  (Compare against DisposeAnyWindow.)
  451. */
  452.  
  453.  
  454.  
  455. void        DisposeAnyWindow(WindowPtr window);
  456. /*
  457.     ¶ Disposes the indicated window.  Also handles if the window is a DA window.
  458.  
  459.     INPUT:    window        The window to dispose.
  460.  
  461.     Disposes of the indicated window.  Does the right thing, taking into account that the window may
  462.     belong to a DA.
  463.  
  464.     WARNING: An application window is closed via a DisposeWindow call.  Use this call when you want
  465.              to free up the storage for the window record.  (Compare against CloseAnyWindow.)
  466. */
  467.  
  468.  
  469.  
  470. void        DeathAlert(short errResID, short errStringIndex);
  471. /*
  472.     ¶ Display an alert that tells the user an error occurred, then exit the program.
  473.  
  474.     INPUT:    errResID            Resource ID of 'STR#' resource holding death alert string.
  475.             errStringIndex        String # of string in 'STR#' resource.
  476.  
  477.     Display an alert that tells the user an error occurred, then exit the program. This routine is
  478.     used as an ultimate bail-out for serious errors that prohibit the continuation of the application.
  479. */ 
  480.  
  481.  
  482.  
  483. void        DeathAlertMessage(short errResID, short errStringIndex, short message);
  484. /*
  485.     ¶ Display an alert that tells the user an error occurred, then exit the program.
  486.  
  487.     INPUT:    errResID            Resource ID of 'STR#' resource holding death alert string.
  488.             errStringIndex        String # of string in 'STR#' resource.
  489.             message                Error number.  If non-0, it is appended to the alert text.
  490.  
  491.     Display an alert that tells the user an error occurred, then exit the program. This routine is
  492.     used as an ultimate bail-out for serious errors that prohibit the continuation of the application.
  493. */ 
  494.  
  495.  
  496.  
  497. void        ErrorAlert(short errResID, short errStringIndex);
  498. /*
  499.     ¶ Display an alert that tells the user an error occurred.
  500.  
  501.     INPUT:    errResID            Resource ID of 'STR#' resource holding error alert string.
  502.             errStringIndex        String # of string in 'STR#' resource.
  503.  
  504.     Display an alert that tells the user an error occurred.
  505. */ 
  506.  
  507.  
  508.  
  509. void        ErrorAlertMessage(short errResID, short errStringIndex, short message);
  510. /*
  511.     ¶ Display an alert that tells the user an error occurred.
  512.  
  513.     INPUT:    errResID            Resource ID of 'STR#' resource holding error alert string.
  514.             errStringIndex        String # of string in 'STR#' resource.
  515.             message                Error number.  If non-0, it is appended to the alert text.
  516.  
  517.     Display an alert that tells the user an error occurred.
  518. */ 
  519.  
  520.  
  521.  
  522. OSErr        FindSysFolder(short *foundVRefNum, long *foundDirID);
  523. /*
  524.     ¶ FindSysFolder returns real vRefNum, and the DirID of the current system folder.
  525.  
  526.     OUTPUT:    foundVRefNum        Volume refNum found is returned here.
  527.             foundDirID            Directory ID found is returned here.
  528.     RESULT:    OSErr
  529.  
  530.     FindSysFolder returns the (real) vRefNum, and the DirID of the current system folder.  It uses
  531.     the Folder Manager if present, otherwise it falls back to SysEnvirons.  It returns zero on
  532.     success, otherwise a standard system error.
  533.  
  534.     This function is only really useful for system 6 compatibility, as system 7 has this
  535.     functionality.
  536. */
  537.  
  538.  
  539.  
  540. Handle        GetAppIndResource(ResType theType, short index, OSErr *err);
  541. /*
  542.     ¶ GetAppIndResource gets a resource from the application's res file by index.
  543.  
  544.     INPUT:    theType        Resource type to get.
  545.             index        Index into resource of type theType.
  546.     OUTPUT:    err            Errors are returned here.
  547.     RESULT:    Handle        The resource.
  548.  
  549.     GetAppIndResource gets a resource from the application's res file by index.
  550. */
  551.  
  552.  
  553.  
  554. Handle        GetAppNamedResource(ResType theType, StringPtr name, OSErr *err);
  555. /*
  556.     ¶ GetAppIndResource gets a resource from the application's res file by name.
  557.  
  558.     INPUT:    theType        Resource type to get.
  559.             name        Name of resource to get.
  560.     OUTPUT:    err            Errors are returned here.
  561.     RESULT:    Handle        The resource.
  562.  
  563.     GetAppIndResource gets a resource from the application's res file by name.
  564. */
  565.  
  566.  
  567.  
  568. Handle        GetAppResource(ResType theType, short theID, OSErr *err);
  569. /*
  570.     ¶ GetAppIndResource gets a resource from the application's res file by ID.
  571.  
  572.     INPUT:    theType        Resource type to get.
  573.             theID        ID of resource to get.
  574.     OUTPUT:    err            Errors are returned here.
  575.     RESULT:    Handle        The resource.
  576.  
  577.     GetAppResource gets a resource from the application's res file by ID.
  578. */
  579.  
  580.  
  581.  
  582. short        GetAUXVersion(void);
  583. /*
  584.     ¶ Checks for the presence of A/UX by whatever means is appropriate.
  585.  
  586.     OUTPUT:    short    Major version number of A/UX.
  587.  
  588.     getAUXVersion -- Checks for the presence of A/UX by whatever means is appropriate.  Returns the
  589.     major version number of A/UX (i.e. 0 if A/UX is not present, 1 for any 1.x.x version 2 for any
  590.     2.x version, etc.  This code should work for all past, present and future A/UX systems.
  591. */
  592.  
  593.  
  594.  
  595. short        GetButtonVariant(ControlHandle ctl);
  596. /*
  597.     ¶ Returns which kind of button the control is.
  598.  
  599.     INPUT:    ctl        Handle to determine button type of.
  600.  
  601.     This function returns which kind of button the control is.  This does more than GetCVariant in
  602.     that it makes sure that the control is actually a button.  It does this by comparing the defProc
  603.     against the known defProc for the various button types.  For 7.0, there is only one defProc for
  604.     all variants, but for pre-7.0, there is one defProc value for each variant.
  605.     The function handles either case.
  606. */
  607.  
  608.  
  609.  
  610. OSErr        SimpleCanDialog(void);
  611. /*
  612.     ¶ Check to see if dialogs are allowed.
  613.  
  614.     RESULT:    OSErr
  615.  
  616.     Check to see if dialogs are allowed.  They may not be if AppleScript is running the show.
  617.     If so, then a non-0 value is returned, and you should not display the dialog.
  618. */
  619.  
  620.  
  621.  
  622. DialogPtr    GetCenteredDialog(short id, DialogPtr storage, WindowPtr relatedWindow, WindowPtr behind);
  623. /*
  624.     INPUT:    id                Resource ID of dialog to center.
  625.             storage            Pointer to dialog record area, or nil for it to be created.
  626.             relatedWindow    Window (or dialog) that dialog being created should follow.
  627.             behind            Window (or dialog) thta dialog being created should be placed behind.
  628.     RESULT:    DialogPtr        The dialog created, or nil if failure.
  629.  
  630.     Given a dialog ID and a related window pointer, this routine will center the dialog on the same
  631.     device as the related window.  If the related window pointer is nil, then the dialog will be
  632.     centered on the device that the dialog would normally be placed if GetNewDialog was called.
  633. */
  634.  
  635.  
  636.  
  637. WindowPtr    GetCenteredWindow(short id, Ptr storage, Boolean vis, WindowPtr relWindow,
  638.                               WindowPtr behind, Boolean inColor, Rect sizeInfo, long refCon);
  639. /*
  640.     ¶ Center the window on the same device as the related window.
  641.  
  642.     INPUT:    id                ID of 'WIND' resource.
  643.             storage            Pointer to space for WindowRecord, or nil to have it created.
  644.             vis                True if window should be created visible.
  645.             relWindow        Window that the new window should "follow" screen-wise.
  646.             behind            Window that the new window should be created behind.
  647.             inColor            True if window should be created as a color window.
  648.             sizeInfo        Min and max sizes for the window.
  649.                             sizeInfo.top    = Minimum height of window.
  650.                             sizeInfo.left   = Minimum width of window.
  651.                             sizeInfo.bottom = Maximum height of window.
  652.                             sizeInfo.right  = Maximum width of window.
  653.                                 If any of the above sizeInfo fields are 0, then that field
  654.                                 has no effect on limiting the change.
  655.             refCon            Regular window refCon.
  656.     RESULT:    WindowPtr        Window that was created, or nil upon failure.
  657.  
  658.     Given a window ID and a related window pointer, this routine will center the window on the same
  659.     device as the related window.  If the related window pointer is nil, then the window will be
  660.     centered on the device that the window would normally be placed if GetNewWindow was called.  The
  661.     function is also passed the sizeInfo rect, which holds min and max size information for the
  662.     window.  (See GetSomeKindOfWindow.)
  663. */
  664.  
  665.  
  666.  
  667. Boolean     GetCheckOrRadio(DialogPtr dlgPtr, short itemNo);
  668. /*
  669.     ¶ Return true if dialog item is a check box or radio button.
  670.  
  671.     INPUT:    dlgPtr        Dialog whose item is being checked.
  672.             itemNo        Item to test to see if a checkbox or radio button.
  673.     RESULT:    Boolean        True returned if item is a checkbox or radio button.
  674.  
  675.     Returns true if dialog item is a check box or radio button.
  676. */
  677.  
  678.  
  679.  
  680. long        GetGestaltResult(OSType gestaltSelector);
  681. /*
  682.     ¶ Returns the result value from Gestalt for the specified selector.
  683.  
  684.     INPUT:    gestaltSelector        Regular Gestalt selector value.
  685.     RESULT:    long                Gestalt value.
  686.  
  687.     GetGestaltResult returns the result value from Gestalt for the specified selector.  If Gestalt
  688.     returned an error GetGestaltResult returns zero.  Use of this function is only cool if we don't
  689.     care whether Gestalt returned an error.  In many cases you may need to know the exact Gestalt
  690.     error code so then this routine would be inappropriate.
  691. */
  692.  
  693.  
  694.  
  695. Point        GetGlobalMouse(void);
  696. /*
  697.     ¶ Returns the location of the mouse in local coordinates.
  698.  
  699.     RESULT:    Point        Mouse location in local coordidates, based on the current grafPort.
  700.  
  701.     Returns the location of the mouse in local coordinates. It does this by calling OSEventAvail.
  702. */
  703.  
  704.  
  705.  
  706. Point        GetGlobalTopLeft(WindowPtr window);
  707. /*
  708.     ¶ Return the top left point of the window’s port in global coordinates.
  709.  
  710.     INPUT:    window        Window whose upper-left is to be returned.
  711.     RESULT:    Point        Upper-left, in local coordinates, of the window.
  712.  
  713.     Given a window, this will return the top left point of the window’s port in global coordinates.
  714.     Something this doesn’t include, is the window’s drag region (or title bar). This returns the top
  715.     left point of the window’s content area only.
  716. */
  717.  
  718.  
  719.  
  720. long        GetKFreeSpace(short vRefNum);
  721. /*
  722.     ¶ Return the amount of free space on the volume in KBytes.
  723.  
  724.     INPUT:    vRefNum        Volume reference to get free space for.
  725.     RESULT:    long        Amount free on volume.
  726.  
  727.     Return the amount of free space on the volume in KBytes. -1 is returned as the size if there
  728.     is an error.
  729. */
  730.  
  731.  
  732.  
  733. Rect        GetMainScreenRect(void);
  734. /*
  735.     ¶ Return rect of main screen, i.e., the screen with the window bar.
  736.  
  737.     RESULT:    Rect        Bounding rect of main screen, including menu bar.
  738.  
  739.     Return rect of main screen, i.e., the screen with the window bar.
  740. */
  741.  
  742.  
  743.  
  744. GDHandle    GetRectDevice(Rect globalRect);
  745. /*
  746.     ¶ Find the greatest overlap device for the given global rectangle.
  747.  
  748.     INPUT:    globalRect        Rect to intersect with devices.
  749.             GDHandle        Graphics device containing the most of the rect.
  750.  
  751.     Find the greatest overlap device for the given global rectangle.  This function assumes that you
  752.     have a system that GDHandle can happen.  If you call this function on other QuickDraws, you
  753.     will crash.
  754. */
  755.  
  756.  
  757.  
  758. Rect        GetRectDeviceRect(Rect globalRect);
  759. /*
  760.     ¶ Find the rect of the greatest overlap device for the given global rect.
  761.  
  762.     INPUT:    globalRect        Rect to intersect devices with.
  763.     RESULT:    Rect            Rect of device containing the most of the rect.
  764.  
  765.     Find the rect of the greatest overlap device for the given global rect.
  766. */
  767.  
  768.  
  769.  
  770. WindowPtr    GetSomeKindOfWindow(PositionWndProcPtr whatKind, short windID, Ptr storage,
  771.                                 Boolean vis, WindowPtr relatedWindow, WindowPtr behind,
  772.                                 Boolean inColor, Rect sizeInfo, long refCon);
  773. /*
  774.     INPUT:    whatKind        ProcPtr to window positioning routine.  This function would be an
  775.                             application-specific replacement of GetCenteredWindow, for example.
  776.             windID            ID of 'WIND' resource.
  777.             storage            Pointer to space for WindowRecord, or nil to have it created.
  778.             vis                True if window should be created visible.
  779.             relatedWindow    Window that the new window should "follow" screen-wise.
  780.             behind            Window that the new window should be created behind.
  781.             inColor            True if window should be created as a color window.
  782.             sizeInfo        Min and max sizes for the window.
  783.                             sizeInfo.top    = Minimum height of window.
  784.                             sizeInfo.left   = Minimum width of window.
  785.                             sizeInfo.bottom = Maximum height of window.
  786.                             sizeInfo.right  = Maximum width of window.
  787.                                 If any of the above sizeInfo fields are 0, then that field
  788.                                 has no effect on limiting the change.
  789.             refCon            Regular window refCon.
  790.     RESULT:    WindowPtr        Window that was created, or nil upon failure.
  791.  
  792.     Given a window positioning procedure pointer, a window ID and a window pointer the window relates
  793.     to, this function open a new window by either a NewCWindow or a NewWindow call, depending on the
  794.     value of inColor.  The window will be opened invisible, independent of what the resource says.
  795.     Once the window is opened successfully, the positioning procedure is called.  The positioning
  796.     procedure is passed a pointer to the just-opened invisible window,a pointer to the related
  797.     window, and the sizeInfo rect.  The sizeInfo rect holds the minimum size in the upper-left point,
  798.     and the max size in the lower-left point.  It is up to the positioning procedure to move the
  799.     invisible window to the correct location on the correct device.  Once the positioning procedure
  800.     returns, the window will be made visible if so indicated by the resource.
  801. */
  802.  
  803.  
  804.  
  805. WindowPtr    GetStaggeredWindow(short id, Ptr storage, Boolean vis, WindowPtr relWindow,
  806.                                WindowPtr behind, Boolean inColor, Rect sizeInfo, long refCon);
  807. /*
  808.     ¶ Stagger the window on the same device as the related window.
  809.  
  810.     INPUT:    id                ID of 'WIND' resource.
  811.             storage            Pointer to space for WindowRecord, or nil to have it created.
  812.             vis                True if window should be created visible.
  813.             relWindow        Window that the new window should "follow" screen-wise.
  814.             behind            Window that the new window should be created behind.
  815.             inColor            True if window should be created as a color window.
  816.             sizeInfo        Min and max sizes for the window.
  817.                             sizeInfo.top    = Minimum height of window.
  818.                             sizeInfo.left   = Minimum width of window.
  819.                             sizeInfo.bottom = Maximum height of window.
  820.                             sizeInfo.right  = Maximum width of window.
  821.                                 If any of the above sizeInfo fields are 0, then that field
  822.                                 has no effect on limiting the change.
  823.             refCon            Regular window refCon.
  824.     RESULT:    WindowPtr        Window that was created, or nil upon failure.
  825.  
  826.     Given a window ID and a related window pointer, this routine will stagger the window on the same
  827.     device as the related window.  If the related window pointer is nil, then the window will be
  828.     staggered on the device that the window would normally be placed if GetNewWindow was called.
  829.     The function is also passed the sizeInfo rect, which holds min and max size information for
  830.     the window.  (See GetSomeKindOfWindow.)
  831. */
  832.  
  833.  
  834.  
  835. void        GetSystemInfo(void);
  836. /*    ¶ Sets up some global variables for use by the utilities package and your application.
  837.  
  838.     This sets up some global variables for use by the utilities package and your application.
  839.     If you call StandardInitialization, you don't need to call this, as it will do it for you.
  840. */
  841.  
  842.  
  843.  
  844. TrapType    GetTrapType(short theTrap);
  845. /*
  846.     ¶ Returns the type (OSType or ToolType) of the trap.
  847.  
  848.     INPUT:    theTrap        Trap to get type for.
  849.  
  850.     Returns the type (OSType or ToolType) of the trap.  It does this by checking the bits of the
  851.     trap word.
  852. */
  853.  
  854.  
  855.  
  856. Rect        GetWindowContentRect(WindowPtr window);
  857. /*    ¶ Get the global rectangle that encloses the content area of the window.
  858.  
  859.     INPUT:    window        Window to get content area rect for.
  860.     RESULT:    Rect        Content area of rect, in global coordinates.
  861.  
  862.     Given a window pointer, return the global rectangle that encloses the content area of the window.
  863. */
  864.  
  865.  
  866.  
  867. short        GetWindowCount(Boolean includeDAs, Boolean includeDLOGs, Boolean includeInvisibles);
  868. /*
  869.     ¶ Counts the number of windows in the application plane.
  870.  
  871.     INPUT:    includeDAs            Include DA windows in count.
  872.             includeDLOGs        Include dialog windows in count.
  873.             includeInvisibles    Also count invisible windows.
  874.  
  875.     This procedure counts the number of windows in the application plane.  You have the choices of
  876.     also counting DAs, DLOGs, and invisible windows in this count.
  877. */
  878.  
  879.  
  880.  
  881. GDHandle    GetWindowDevice(WindowPtr window);
  882. /*
  883.     ¶ Find the greatest overlap device for the given window.
  884.  
  885.     INPUT:    window        Window to determine device for.
  886.     OUTPUT:    GDHandle    Device containing largest portion of the window.
  887.  
  888.     Find the greatest overlap device for the given window.
  889. */
  890.  
  891.  
  892.  
  893. Rect        GetWindowDeviceRect(WindowPtr window);
  894. /*
  895.     ¶ Find device that contains most of the window and return device's bounding rectangle.
  896.  
  897.     INPUT:    window        Window to check against the devices.
  898.     OUTPUT:    Rect        Bounding rect of device containing the most of the window.
  899.  
  900.     Given a window pointer, find the device that contains most of the window and return the
  901.     device's bounding rectangle.
  902. */
  903.  
  904.  
  905.  
  906. Rect        GetWindowDeviceRectNMB(WindowPtr window);
  907. /*
  908.     ¶ Bounding rect of device containing most of the window, less menu bar.
  909.  
  910.     INPUT:    window        Window to check against the devices.
  911.     OUTPUT:    Rect        Bounding rect of device containing the most of the window.
  912.  
  913.     Given a window pointer, find the device that contains most of the window and return the
  914.     device's bounding rectangle, less the menu bar if it is on that device.
  915. */
  916.  
  917.  
  918. Rect        GetWindowStructureRect(WindowPtr window);
  919. /*
  920.     ¶ Get the rectangle that surrounds the entire structure of a window.
  921.  
  922.     INPUT:    window        Window to get structure rect for.
  923.     OUTPUT:    Rect        Bounding rect of structure region for window.
  924.  
  925.     This procedure is used to get the rectangle that surrounds the entire structure of a window.
  926.     This is true whether or not the window is visible.  If the window is visible, then it is a
  927.     simple matter of using the bounding rectangle of the structure region.  If the window is
  928.     invisible, then the strucRgn is not correct.  To make it correct, then window has to be moved
  929.     way off the screen and then made visible.  This generates a valid strucRgn, although it is valid
  930.     for the position that is way off the screen.  It still needs to be offset back into the original
  931.     position.  Once the bounding rectangle for the strucRgn is obtained, the window can then be
  932.     hidden again and moved back to its correct location.  Note that ShowHide is used, instead of
  933.     ShowWindow and HideWindow.  HideWindow can change the plane of the window.  Also, ShowHide does
  934.     not affect the hiliting of windows.
  935. */
  936.  
  937.  
  938.   
  939. void        GlobalToLocalRect(Rect *aRect);
  940. /*
  941.     ¶ Convert the global rect to local coordinates, based on the current grafPort.
  942.  
  943.     IN/OUT:    Rect        INPUT:    Global rectange to convert to local.
  944.                         OUTPUT:    Rectangle in local coordinates.
  945.  
  946.     Convert the global rect to local coordinates, based on the current grafPort.
  947. */
  948.  
  949.  
  950.  
  951. void        InitToolBox(void);
  952. /*
  953.     ¶ Initialize the toolbox in the “standard” way for applications.
  954.  
  955.     Initialize the toolbox in the “standard” way for applications.
  956. */
  957.  
  958.  
  959.  
  960. Boolean        IsAppWindow(WindowPtr window);
  961. /*
  962.     ¶ Return true if the windowKind of the window is greater than or equal to userKind.
  963.  
  964.     INPUT:    window        Window to test for user-kindness.
  965.     RESULT:    Boolean        True if window is >= userKind.
  966.  
  967.     Returns TRUE if the windowKind of the window is greater than or equal to userKind. If it is
  968.     less, or the window is NIL, then return FALSE.
  969. */
  970.  
  971.  
  972.  
  973. Boolean        IsDAWindow(WindowPtr window);
  974. /*
  975.     ¶ Return true if the windowKind of the window is less than zero.
  976.  
  977.     INPUT:    window        Window to check for DA-ness.
  978.     OUTPUT:    Boolean        True if window is a DA window.
  979.  
  980.     Returns true if the windowKind of the window is less than zero. If not, or the window is nil,
  981.     then return FALSE.
  982. */
  983.  
  984.  
  985.  
  986. Boolean        IsScrollBar(ControlHandle ctl);
  987. /*
  988.     ¶ Return true if the control is a scrollbar.
  989.  
  990.     INPUT:    ctl            Control to test to see if it is a scrollbar.
  991.     RESULT:    Boolean        True if the control is a scrollbar.
  992.  
  993.     Returns TRUE if the control is a scrollbar.
  994. */
  995.  
  996.  
  997.  
  998. void        LocalToGlobalRect(Rect *aRect);
  999. /*
  1000.     ¶ Convert the local rect to global coordinates, based on the current grafPort.
  1001.  
  1002.     IN/OUT:    Rect        INPUT:    Local rectange to convert to global.
  1003.                         OUTPUT:    Rectangle in global coordinates.
  1004.  
  1005.     Convert the local rect to global coordinates, based on the current grafPort.
  1006. */
  1007.  
  1008.  
  1009.  
  1010. char        LockHandleHigh(Handle theHandle);
  1011. /*
  1012.     ¶ Does a MoveHHi on the handle and then locks it.
  1013.  
  1014.     INPUT:    theHandle        Handle to lock high.
  1015.     RESULT:    char            Old state of the handle.
  1016.  
  1017.     Does a MoveHHi on the handle and then locks it.  Also, the original state of the handle is
  1018.     returned, so you can keep it and set the handle back to it's original state with a
  1019.     HSetState call.
  1020. */
  1021.  
  1022.  
  1023.  
  1024. short        NumToolboxTraps(void);
  1025. /*
  1026.     ¶ Determines the size of the Tool trap table.
  1027.  
  1028.     RESULT:    short        Size of the tool trap table.
  1029.  
  1030.     Determines the size of the Tool trap table. It does this by sampling a couple of trap locations
  1031.     and seeing which, if any are Unimplemented.
  1032. */
  1033.  
  1034.  
  1035.  
  1036. void        OutlineControl(ControlHandle button);
  1037. /*
  1038.     ¶ Draw the default indicator around the control.
  1039.  
  1040.     INPUT:    button        Control to draw the indicator around.
  1041.  
  1042.     Draw the default indicator around the control.
  1043. */
  1044.  
  1045.  
  1046.  
  1047. void         OutlineDialogItem(DialogPtr dlgPtr, short item);
  1048. /*
  1049.     ¶ Draw the default indicator around the dialog item.
  1050.  
  1051.     INPUT:    dlgPtr        Dialog that owns the item.
  1052.             item        Item to draw a dialog selector around.
  1053.  
  1054.     Draw the default indicator around the dialog item.
  1055. */
  1056.  
  1057.  
  1058.  
  1059. void        PositionRectInRect(Rect outerRect, Rect *innerRect, Fixed horzRatio, Fixed vertRatio);
  1060. /*
  1061.     ¶ Positions one rect within another, based on a ratio.
  1062.  
  1063.     INPUT:    outerRect        Rect to position within.
  1064.             horzRatio        Ratio for horizontal positioning.
  1065.             vertRatio        Ratio for vertical positioning.
  1066.     IN/OUT:    innerRect        INPUT:    Rect to position.
  1067.                             OUTPUT:    Positioned rect.
  1068.     
  1069.     Given two rectangles, this routine positions the second within the first one so that the it
  1070.     maintains the spacing specified the the horzRatio and vertRatio parameters. In other words, to
  1071.     center an inner rectangle hoizontally, but have its center be 1/3 from the top of the outer
  1072.     rectangle, call this routine with horzRatio = FixRatio(1, 2), vertRatio = FixRatio(1, 3).
  1073. */
  1074.  
  1075.  
  1076.  
  1077. void        PullApplicationToFront(void);
  1078. /*
  1079.     ¶ Bring the application to the front.
  1080.  
  1081.     Bring the application to the front.
  1082. */
  1083.  
  1084.  
  1085.  
  1086. void        SelectButton(ControlHandle button);
  1087. /*
  1088.     ¶ Cause the button to look as if it has been clicked on.
  1089.  
  1090.     INPUT:    button        Control to flash, as if clicked on.
  1091.  
  1092.     Given the button control handle, this will cause the button to look as if it has been clicked in.
  1093.     This is nice to do for the user if they type return or enter to select the default item.
  1094. */
  1095.  
  1096.  
  1097.  
  1098. void        SetCheckOrRadioButton(DialogPtr dlgPtr, short itemNo, short state);
  1099. /*
  1100.     ¶ Set the value of a dialog item.
  1101.  
  1102.     INPUT:    dlgPtr        Dialog whose item is to be changed.
  1103.             itemNo        Item to change value for.
  1104.             state        New value for the item.
  1105.  
  1106.     Handy function for setting the value of a radio button.  Given a dialog pointer, and item number,
  1107.     and a state, this function will take care of the rest.
  1108. */
  1109.  
  1110.  
  1111.  
  1112. Rect        StaggerWindow(WindowPtr window, WindowPtr relatedWindow, Rect sizeInfo);
  1113. /*
  1114.     ¶ Stagger the window on the same device as the related window.
  1115.  
  1116.     INPUT:    window                Window to stagger.
  1117.             relatedWindow        Window to "follow" when staggering.
  1118.             sizeInfo            Min and max sizes for the window.
  1119.                                 sizeInfo.top    = Minimum height of window.
  1120.                                 sizeInfo.left   = Minimum width of window.
  1121.                                 sizeInfo.bottom = Maximum height of window.
  1122.                                 sizeInfo.right  = Maximum width of window.
  1123.                                     If any of the above sizeInfo fields are 0, then that field
  1124.                                     has no effect on limiting the change.
  1125.  
  1126.     This algorithm for staggering windows does quite a good job.  It also is quite gnarly.
  1127.     Here's the deal:
  1128.  
  1129.     There are pre-designated positions that we will try when positioning a window.  These slots will
  1130.     be tried from the upper-left corner towards the lower-right corner.  If there are other windows
  1131.     in that slot, then we will consider that slot taken, and proceed to the next slot.  A slot is
  1132.     determined to be taken by checking a point with a slop area.  This slop area is diamond-shaped,
  1133.     not simply rectangular.  If there is no other visible window with an upper-left corner within the
  1134.     slop diamond, then we are allowed to position our window there.  The above rule holds true unless
  1135.     this forces the window to be partly off the screen.  If the window ends up partly off the screen,
  1136.     then we give up and just put it in the first slot.
  1137. */
  1138.  
  1139.  
  1140.  
  1141. void        StandardAbout(short appNameStringID);
  1142. /*
  1143.     ¶ Shows a standard about box.
  1144.  
  1145.     INPUT:    appNameStringID        ID of the 'STR ' resource which contains the application name.
  1146.  
  1147.     Shows a standard about box with the name of the application, its version number, a copyright
  1148.     notice, and DTS credits. Most of this information is taking from a standard DITL and the
  1149.     application’s 'vers' resource. The name of the application is taken either from the 'STR '
  1150.     resource passed in to this routine, or from GetAppParms if that resource doesn’t exist,
  1151.     or you pass in -1.
  1152. */
  1153.  
  1154.  
  1155.  
  1156. void        StandardInitialization(short callsToMoreMasters);
  1157. /*
  1158.     ¶ Do the standard AppsToGo application initializaition thing.
  1159.  
  1160.     INPUT:    callsToMoreMasters        Number of times MoreMasters should be called.
  1161.  
  1162.     • Initializes “gInBackGround” to FALSE. Makes the following InitXXX calls:
  1163.         InitGraf, InitFonts, InitWindows, InitMenus, TEInit,
  1164.         InitDialogs, InitCursor.
  1165.     • Brings application to front with 3 EventAvail calls.
  1166.     • Calls SysEnvirons to initialize “gMac”. Calls TrapExists to initialize “gHasWaitNextEvent”.
  1167. */
  1168.  
  1169.  
  1170.    
  1171. void        StandardMenuSetup(short MBARID, short AppleMenuID);
  1172. /*
  1173.     ¶ Installs and draws the menus indicated by 'MBAR'(MBARID), and more.
  1174.  
  1175.     INPUT:    MBARID            Menu bar ID to initialize with.
  1176.             AppleMenuID        ID of Apple menu.  Used with AddResMenu.
  1177.  
  1178.     Installs and draws the menus indicated by 'MBAR'(MBARID). Adds DA’s to the menu indicated by
  1179.     AppleMenuID by calling AddResMenu. If the menuBar cannot be created, the alert specified by
  1180.     rDeathAlert is displayed.
  1181. */
  1182.  
  1183.  
  1184.  
  1185. void        InsertHierMenus(MenuHandle menu);
  1186. /*
  1187.     ¶ Look through the menu items for hierarchical references and handle them.
  1188.  
  1189.     INPUT:    menu        Menu to scan for hierarchical references.
  1190.  
  1191.     Look through the menu items for hierarchical references.  For each found, insert the hierarchical
  1192.     menu, and then recursively search that menu for hierarchical menus.  This function is called by
  1193.     StandardMenuSetup so that all hierarchical menus are inserted at application startup time. 
  1194. */
  1195.  
  1196.  
  1197.  
  1198. void         ToggleCheck(DialogPtr dlgPtr, short cChkItem);
  1199. /*
  1200.     ¶ Toggle the value of a dialog checkbox item.
  1201.  
  1202.     INPUT:    dlgPtr        Dialog which contains the item to toggle.
  1203.             cChkItem    Checkbox item to toggle.
  1204.  
  1205.     Toggle the value of a dialog checkbox item.
  1206. */
  1207.  
  1208.  
  1209.  
  1210. Boolean        TrapExists(short theTrap);
  1211. /*
  1212.     ¶ Returns true if the trap exists.
  1213.  
  1214.     INPUT:    theTrap        The trap number.
  1215.     RESULT:    Boolean        True if trap exists.
  1216.  
  1217.     Returns TRUE if the trap exists (i.e., it’s callable without getting DS error 12).
  1218. */
  1219.  
  1220.  
  1221.  
  1222. Boolean        WhichControl(Point mouseLoc, long when, WindowPtr window, ControlHandle *ctlHit);
  1223. /*
  1224.     ¶ Return which visible control mouseLoc is within, independent of contorl state.
  1225.  
  1226.     INPUT:    mouseLoc        Mouse location, in local coordinates.
  1227.             when            TickCount value of when click occured.  Used to determine if the
  1228.                             click is a double click on the control.
  1229.             window            Window containing the controls to test.
  1230.     OUTPUT:    ctlHit            The control that was hit, if any.
  1231.     RESULT:    Boolean            True if a control was hit.
  1232.  
  1233.     Returns which visible control mouseLoc is within, independent of the state of the control.
  1234.     Scrollbars that are inactive are not found by FindControl.
  1235. */
  1236.  
  1237.  
  1238.  
  1239. void        ZoomToWindowDevice(WindowPtr window, short maxWidth, short maxHeight,
  1240.                                short zoomDir, Boolean front);
  1241. /*
  1242.     ¶ Zoom the window to size appropriate for device containing most of the window.
  1243.  
  1244.     INPUT:    window        The window to zoom.
  1245.             maxWidth    The maximum width that the zoom should cause.
  1246.             maxHeight    The maximum height that the zoom should cause.
  1247.             zoomDir        Direction of zoom (in or out).
  1248.             front        True if window should be brought to front, in addition to zooming.
  1249.  
  1250.     Zoom the window to the size appropriate for the device that contains the most of the window.
  1251.     An additional feature is that you can state the maximum that a window should be zoomed, either
  1252.     horizontally or vertically.  If you pass in a maximum of 0 for the zoom for either direction,
  1253.     then that direction will be zoomed to fit the device.
  1254. */
  1255.  
  1256.  
  1257.  
  1258. pascal Boolean    AlertFilter(DialogPtr dlg, EventRecord *event, short *item);
  1259. /*
  1260.     ¶ The alert filter makes sure that that the outline for the button gets redrawn.
  1261.  
  1262.     INPUT:    dlg            The dialog the event is for.
  1263.             event        The event to filter.
  1264.     IN/OUT:    item        The item related to the event/filter.
  1265.     RESULT:    Boolean        Same return result as an Alert filter.
  1266.  
  1267.     The alert filter makes sure that that the outline for the button gets redrawn.  This is important
  1268.     if balloon help is on, as the balloon window can overlap the outline of the button and leave a
  1269.     portion of it erased.
  1270. */
  1271.  
  1272.  
  1273.  
  1274. pascal Boolean    KeyEquivFilter(DialogPtr dlg, EventRecord *event, short *item);
  1275. /*
  1276.     ¶ Allows you to assign key equivalents to dialog items.
  1277.  
  1278.     INPUT:    dlg            The dialog the event is for.
  1279.             event        The event to filter.
  1280.     IN/OUT:    item        The item related to the event/filter.
  1281.     RESULT:    Boolean        Same return result as an Alert filter.
  1282.  
  1283.     The key equivalent filter allows you to assign key equivalents to dialog items.  Each item can
  1284.     have as many key equivalents as you wish.  You can also specify the exact state of the modifiers
  1285.     that you will or won't allow.  The key equivalent information is stored in the resource fork, so
  1286.     the key equivalents can be easily localized.
  1287.     This code expects the key equivalents to be in item #2, which is a StatText item that is located
  1288.     so the text is outside of the dialog.  This allows us to put key equivalent information in the
  1289.     resource fork, so the key equivalents are localizable.
  1290.  
  1291.     An example save changes before closing or quitting res source with keyEquiv info would look like:
  1292.  
  1293.     resource 'DITL' (rYesNoCancel, purgeable) {
  1294.         {
  1295.             {71, 315, 91, 367}, Button     { enabled, "Save" },
  1296.             {0, -1000, 20, 2},  StaticText { disabled,
  1297.                 "=S190001,=s190001,=D190003,=d190003,=.190104,1B190004" },
  1298.             {71, 80, 91, 162},  Button { enabled, "Don’t Save" },
  1299.             {71, 244, 91, 302}, Button { enabled, "Cancel" },
  1300.             {11, 78, 61, 366},  StaticText { disabled,
  1301.                 "Save changes to the document “^0” before ^1?" },
  1302.             {11, 23, 43, 55},        Icon { disabled, 2 }
  1303.         }
  1304.     };
  1305.     The document name would be the string for param #0.
  1306.     The text "closing" or "quitting" would be the string for param #1.
  1307.  
  1308.     The keyEquiv entry is item #2, which has a rect that pushes it out of the dialog.  The string
  1309.     info is interpreted as to what the key/modifier combo is, and what dialog item it relates to.
  1310.  
  1311.     A single key equiv entry is 8 characters.  Entries are separated by commas.
  1312.  
  1313.     If the first character of an entry is an =, then the next character is the key.  If the first
  1314.     character isn't an =, then the first two characters are the hex value of the key.
  1315.     (Ex:  =S or =s for save, 1B for ESC.)
  1316.  
  1317.     If the key pressed is the same as the key value for any of the entries, then the next two
  1318.     characters are the hex value for which modifiers to test.  This modifier test value is anded
  1319.     with the modifier.  The result is then compared to the value of the next two hex digits.
  1320.     If they are equal, then the modifiers are correct, as well as the key.  If this is so,
  1321.     we have a winner.
  1322.  
  1323.     "=S190001,=s190001,=D190003,=d190003,=.190104,1B190004"
  1324.  
  1325.     The above string breaks down as follows:
  1326.     =S190001  =S  if event keypress is an S, check the modifier values
  1327.               19  check controlKey/optionKey/cmdKey
  1328.               00  all modifiers we are testing for should be false
  1329.               01  if above is true, keypress maps to item # 1
  1330.     =s190001  Same as =S, but lowercase
  1331.     =D190001  Same as =S, but maps to item #3
  1332.     =d190001  Same as =D, but lowercase
  1333.     =.190104  =.  if event keypress is a period, check the modifier values
  1334.               19  check controlKey/optionKey/cmdKey
  1335.               01  controlKey/optionKey should be false, cmdKey should be true
  1336.               04  if above is true, keypress maps to item # 4
  1337.     1B190004  1B  if event keypress is an ESC, check the modifier values
  1338.               19  check controlKey/optionKey/cmdKey
  1339.               00  all modifiers we are testing for should be false
  1340.               04  if above is true, keypress maps to item # 4
  1341. */
  1342.  
  1343.  
  1344.  
  1345. void            OffsetControl(ControlHandle ctl, short dx, short dy);
  1346. /*
  1347.     ¶ Convenient way to move a control a specified amount.
  1348.  
  1349.     INPUT:    ctl        Control to offset
  1350.             dx        change on horizontal position
  1351.             dy        change in vertical position
  1352.  
  1353.     This function is a convenient way to move a control a specified amount.
  1354. */
  1355.  
  1356.  
  1357.  
  1358. void            DoDrawGrowIcon(WindowPtr window, Boolean horLine, Boolean verLine);
  1359. /*
  1360.     ¶ Draws the grow icon for the window in the specified manner.
  1361.  
  1362.     INPUT:    window        Window to draw growIcon for.
  1363.             horLine        True if you want the horizontal line associated with the growIcon to draw.
  1364.             verLine        True if you want the vertical line associated with the growIcon to draw.
  1365.  
  1366.     This function draws the grow icon for the window in the specified manner.  You can clip out the
  1367.     horizontal or vertical line that is also drawn along with the grow icon, or you can have
  1368.     them draw.
  1369. */
  1370.  
  1371.  
  1372.  
  1373. void            DoDrawControls(WindowPtr window, Boolean scrollBarsOnly);
  1374. /*
  1375.     ¶ Draws all of the controls in a window, or just the scrollbar controls.
  1376.  
  1377.     INPUT:    window                The window whose controls are to be drawn.
  1378.             scrollBarsOnly        If true, only scrollbar controls should be drawn.
  1379.  
  1380.     This function draws all of the controls in a window, or just the scrollbar controls.  The reason
  1381.     for this function is that scrollbars are really tri-state, especially now with 7.0.  A scrollbar
  1382.     can be hilighted or not, or it can be drawn in a window that isn't the frontmost of the
  1383.     application plane.  DoDrawControls takes this third scrollbar state into consideration. 
  1384. */
  1385.  
  1386.  
  1387.  
  1388. void            DoDraw1Control(ControlHandle ctl, Boolean scrollBarsOnly);
  1389. /*
  1390.     ¶ This is where the work for scrollbar/control drawing is actually done.
  1391.  
  1392.     INPUT:    window                The control to draw.
  1393.             scrollBarsOnly        If true, only draw control if scrollbar.
  1394.  
  1395.     This function is where the work for scrollbar/control drawing is actually done.
  1396.     DoDrawControls calls this function for each control in a window.
  1397. */
  1398.  
  1399.  
  1400.  
  1401. ControlHandle    GetPopupCtlHandle(DialogPtr theDialog, short itemNum);
  1402. /*
  1403.     ¶ Given a dialog and its item number and, return the control handle for the popup.
  1404.  
  1405.     INPUT:    theDialog        The dialog that holds the popup.
  1406.             itemNum            The item number of the popup.
  1407.     RESULT:    ControlHandle
  1408.  
  1409.     GetPopupCtlHandle takes a dialog and its item number and (assuming it is a popup menu control)
  1410.     and returns the control handle for the popup.
  1411. */
  1412.  
  1413.  
  1414.  
  1415. MenuHandle    GetPopupMenuHandle(ControlHandle popupCtl);
  1416. /*
  1417.     ¶ Given a popup control, return the menu handle from the control.
  1418.  
  1419.     INPUT:    popupCtl        The popup control to dereference to get the menu handle.
  1420.     RESULT:    MenuHandle        The menu handle of the popup control.
  1421.  
  1422.     GetPopupMenuHandle takes a popup control and returns the menu handle from the control.
  1423. */
  1424.  
  1425.  
  1426.  
  1427. short    GetPopupCtlValue(DialogPtr theDialog, short popItem);
  1428. /*
  1429.     ¶ Given a dialog and its item number and, return the control handle for the popup.
  1430.  
  1431.     INPUT:    theDialog        The dialog that holds the popup.
  1432.             popItem            The item number of the popup.
  1433.     RESULT:    short            The popup control value.
  1434.  
  1435.     GetPopupCtlValue returns value for the popup control.
  1436. */
  1437.  
  1438.  
  1439.  
  1440. void    SetPopupCtlValue(DialogPtr theDialog, short popItem, short value);
  1441. /*
  1442.     ¶ Sets a new value for a popup control.
  1443.  
  1444.     INPUT:    theDialog        The dialog that holds the popup.
  1445.             popItem            The item number of the popup.
  1446.             value            The new popup control value.
  1447.  
  1448.     SetPopupCtlValue makes value the new value for the popup control.
  1449. */
  1450.  
  1451.  
  1452.  
  1453. short    SmartInsMenuItem(MenuHandle theMenu, StringPtr theText, short section, short where);
  1454. /*
  1455.     ¶ "Intelligently" insert a menu item into a menu.
  1456.  
  1457.     INPUT:    theMenu        The menu to insert into.
  1458.             theText        The text for the menu item to be inserted.
  1459.             section        Sections are divided by menu dividing lines.  This tells which
  1460.                         section to insert the menu item into.  Section 1 is all of the items
  1461.                         before the first dividing line.
  1462.             where        Where to insert, relative to the section.
  1463.     RESULT:    short        Menu item number from the beginning of the menu, not beginning of section.
  1464.  
  1465.     This is used to "intelligently" insert a menu item into a menu.  Pass it the menu to be modified,
  1466.     the text of the item being added, plus where the item is to be inserted.  The location to be
  1467.     inserted is described by two parameters:  section & where.
  1468.  
  1469.     section:  Indicates which group of menu items you wish to add an item to.
  1470.               Menu item section 1 is all of the items before the first
  1471.               dividing line.  Menu item section 2 is all items after the
  1472.               first dividing line and before the second, and so on.  If you
  1473.               have no dividing lines, you have just 1 section so pass in 1.
  1474.  
  1475.     where:    Indicates the item position relative to the section.  To add an
  1476.               item such that it is the first item in a section, pass in a 1.
  1477.               It will be added in front of the first item in the section.
  1478.  
  1479.               NOTE:  You should never pass in a section or where parameter of 0.
  1480.  
  1481.     Negative values for "where" are magic.  If where = kMenuItemTxtInsert, then it inserts the
  1482.     item alphabetically into the section.  A where of kMenuItemNumInsert works the same as
  1483.     kMenuItemTxtInsert, except it treats the strings are numbers for comparison purposes.
  1484.     If you want to add the item to the end of a section, use kMenuItemSectionEnd.
  1485.  
  1486.     As a final goodie, SmartInsMenuItem returns the menu item # from the beginning of the menu,
  1487.     not section.
  1488. */
  1489.  
  1490.  
  1491.  
  1492. short    CountMSections(MenuHandle theMenu);
  1493. /*
  1494.     ¶ Return the number of menu sections in a menu.
  1495.  
  1496.     INPUT:    theMenu        The menu whose sections are to be counted.
  1497.     RESULT:    short        The number of sections.
  1498.  
  1499.     Return the number of menu sections.  The number of sections is equal to the number of
  1500.     dividing lines + 1.
  1501. */
  1502.  
  1503.  
  1504.  
  1505. short    FindMenuItem(MenuHandle theMenu, StringPtr cmpTxt);
  1506. /*
  1507.     ¶ Find the menu item number, given the text of the menu.
  1508.  
  1509.     INPUT    theMenu        The menu to search for the text.
  1510.             cmpText        The text to scan for.
  1511.  
  1512.     Find the menu item number, given the text of the menu.
  1513. */
  1514.  
  1515.  
  1516.  
  1517. OSErr    PersistFSSpec(PFSSpecPtr pfss);
  1518. /*
  1519.     ¶ Get an FSSpec to persist when saved to disk.
  1520.  
  1521.     INPUT:    pfss        A persistent-FSSpec record.
  1522.     RESULT:    OSErr
  1523.  
  1524.     Do what is necessary to get an FSSpec to persist when saved to disk.  The parID will still be
  1525.     valid, along with the file name.  The part that isn't valid is the vRefNum.  This function
  1526.     converts the FSSpec's vRefNum to a volume name, or converts the volume name into a vRefNum.
  1527.     An extended FSSpec is used.  The extension is, logically enough, a volume name.  If the
  1528.     FSSpec's vRefNum is non-0, then it fills in the volume name for that vRefNum.  If the vRefNum
  1529.     is 0, it then uses the volume name to generate a vRefNum.  Prior to saving a PFSSpec to disk,
  1530.     call PersistFSSpec.  It will fill in the volume name.  After having read a PFSSpec from disk,
  1531.     set the vRefNum to 0 and then call PersistFSSpec.  It will fill in the vRefNum that corresponds
  1532.     to the volume name.
  1533. */
  1534.  
  1535.  
  1536.  
  1537. StringPtr    PathNameFromDirID(long DirID, short vRefNum, StringPtr str);
  1538. /*
  1539.     ¶ Implementation of tech note #238.
  1540.  
  1541.     INPUT:    DirID        Directory ID to convert to path.
  1542.             vRefNum        Volume of path
  1543.     OUTPUT:    str            The full path name.
  1544.     RESULT:    StringPtr    The full path name.
  1545.  
  1546.     This function is straight out of tech note #238.  See this note for more info.
  1547. */
  1548.  
  1549.  
  1550.  
  1551. void    InitQuickTime(void);
  1552. /*
  1553.     ¶ Generically initializes QuickTime.
  1554.  
  1555.     Call this to generically initialize QuickTime.  It sets two globals:
  1556.         gQTVersion                    QuickTime version (0 means not available).
  1557.         gMovieControllerComponent    QuickTime movie controller component reference.
  1558. */
  1559.  
  1560.  
  1561.  
  1562. RgnHandle    LocalScreenDepthRegion(short depth);
  1563. /*
  1564.     ¶ Same as ScreenDepthRegion, except that it localizes the region.
  1565.  
  1566.     INPUT:    depth            The min depth to be included in the region.
  1567.     RESULT:    RgnHandle        The region of screen area of at least given depth.
  1568.  
  1569.     This function serves the same purpose as ScreenDepthRegion, except that it localizes the region
  1570.     to the current port.  If the global gScreenPort is not nil, then it localizes to that port.
  1571.     The reason for this is that the current port may be an offscreen port.  If it is offscreen,
  1572.     then it doesn't have a direct relationship to the screen.
  1573. */
  1574.  
  1575.  
  1576.  
  1577. void    MoveStyledControl(ControlHandle ctl, short xloc, short yloc);
  1578. /*
  1579.     ¶ Move an AppsToGo styled control.
  1580.  
  1581.     INPUT:    ctl        The ontrol to move.
  1582.             xloc    The new x-location for the control.
  1583.             yloc    The new y-location for the control.
  1584.  
  1585.     This moves an AppsToGo styled control.  Don't just call MoveControl, as the control will be
  1586.     removed and redrawn in possibly the wrong font/size/style, etc.
  1587. */
  1588.  
  1589.  
  1590.  
  1591. void    SizeStyledControl(ControlHandle ctl, short xsize, short ysize);
  1592. /*
  1593.     ¶ Size an AppsToGo styled control.
  1594.  
  1595.     INPUT:    ctl        The ontrol to move.
  1596.             xsize    The new width for the control.
  1597.             ysize    The new height for the control.
  1598.  
  1599.     This resizes an AppsToGo styled control.  Don't just call SizeControl, as the control will be
  1600.     removed and redrawn in possibly the wrong font/size/style, etc.
  1601. */
  1602.  
  1603.  
  1604.  
  1605. void    SetStyledCtlValue(ControlHandle ctl, short value);
  1606. /*
  1607.     ¶ Set the value of an AppsToGo styled control.
  1608.  
  1609.     INPUT:    ctl        The ontrol to move.
  1610.             value    The new value for the control.
  1611.  
  1612.     This sets the control value for an AppsToGo styled control.  Don't just call SetControlValue,
  1613.     as the control will be removed and redrawn in possibly the wrong font/size/style, etc.
  1614. */
  1615.  
  1616.  
  1617.  
  1618. void    ShowStyledControl(ControlHandle ctl);
  1619. /*
  1620.     ¶ Show a hidden AppsToGo styled control.
  1621.  
  1622.     INPUT:    ctl        The control to show.
  1623.  
  1624.     This shows a control that is hidden.  It the control is already shown, nothing is done.
  1625.     Don't just call ShowControl, as the control will be removed and redrawn in possibly the
  1626.     wrong font/size/style, etc.
  1627. */
  1628.  
  1629.  
  1630.  
  1631. void    HideStyledControl(ControlHandle ctl);
  1632. /*
  1633.     ¶ Hide a visible AppsToGo styled control.
  1634.  
  1635.     INPUT:    ctl        The control to hide.
  1636.  
  1637.     This hides a control that is visible.  It the control is already hidden, nothing is done.
  1638.     Don't just call HideControl, as the control will be removed and redrawn in possibly the
  1639.     wrong font/size/style, etc.
  1640. */
  1641.  
  1642.  
  1643.  
  1644. void    UseControlStyle(ControlHandle ctl);
  1645. /*
  1646.     ¶ Set the control's grafPort's font info to that used by the control.
  1647.  
  1648.     INPUT:    ctl        The control whose font info is to be put into the port.
  1649.                     If nil is passed in, the info for that port is reset.
  1650.  
  1651.     This call should bracket direct uses of a control.  For example:
  1652.         UseControlStyle(teCtl);
  1653.         CTEPutPstr(teCtl, "\pThis is the new TextEdit control text.");
  1654.         UseControlStyle(nil);
  1655.  
  1656.     Whenever a TextEdit control has its text completely replaced, as CTEPutPStr does, the
  1657.     font that the TextEdit control is set to is whatever is in the grafPort.  Therefore by
  1658.     calling UseControlStyle prior to CTEPutPStr, we place the TextEdit's custom font into
  1659.     the grafPort.  The second call to UseControlStyle restores the grafPort's previous values.
  1660.     Note that UseControlStyle saves the information to restore in globals, so don't try to
  1661.     nest calls to UseControlStyle.
  1662. */
  1663.  
  1664.  
  1665.  
  1666. void    SetStyledCTitle(ControlHandle ctl, StringPtr title);
  1667. /*
  1668.     ¶ Set the title for an AppsToGo styled control.
  1669.  
  1670.     INPUT:    ctl        The control whose title is to be changed.
  1671.  
  1672.     Set an AppsToGo control title to new text.  Don't just call hideControl, as the control will
  1673.     be removed and redrawn in possibly the wrong font/size/style, etc.
  1674. */
  1675.  
  1676.  
  1677.  
  1678. short    GetControlID(ControlHandle ctl);
  1679. /*
  1680.     ¶ Get the control's ID out of the control's extended control record.
  1681.  
  1682.     INPUT:    ctl            The control handle to get the control ID for.
  1683.     RESULT:    short        The control ID.
  1684.  
  1685.     AppsToGo allows you to assign controls a short value for an ID.  If you have the control handle,
  1686.     this is how you convert it to the ID for that control.
  1687. */
  1688.  
  1689.  
  1690.  
  1691. Boolean    GetControlStyle(ControlHandle ctl, ControlStyleInfoPtr cinfo);
  1692. /*
  1693.     ¶ Get the extended control record for the control.
  1694.  
  1695.     INPUT:    ctl            The control to get style information for.
  1696.             cinfo        The control style record returned.
  1697.     RESULT:    Boolean        True if the control has extended style information.
  1698.  
  1699.     AppsToGo controls generally have an extended control record.  To get this information, you
  1700.     only have this single accesssor function, which returns you all of the data in a structure.
  1701.     If the control has an extended record, then true is returned.  If the control doesn't have
  1702.     an AppsToGo extended control record, then false is returned.
  1703. */
  1704.     
  1705.  
  1706.  
  1707. OSErr    SetControlStyle(ControlHandle ctl, ControlStyleInfoPtr cinfo);
  1708. /*
  1709.     ¶ Create, replace, or remove the control's extended control record.
  1710.  
  1711.     INPUT:    ctl            Control whose extended control record is to modified.
  1712.             cinfo        A styled control's extended control record.
  1713.                             • If the control doesn't have an extended control record, then
  1714.                               one is created for it.
  1715.                             • If the control already has an extended control record,
  1716.                               then it's replaced.
  1717.                             • If the pointer is nil, then if the control has an extended control,
  1718.                               it is removed.
  1719.     RESULT:    OSErr        Most likely memFullErr.
  1720.  
  1721.     Add, replace, or remove the control's extended style record, according to the above rules.
  1722. */
  1723.  
  1724.  
  1725.  
  1726. void    SetTrackControlProc(ControlHandle ctl, TrackControlProcPtr proc);
  1727. /*
  1728.     ¶ Set a track control proc for the control.
  1729.  
  1730.     INPUT:    ctl        The control which needs a custom track procedure.
  1731.             proc    The procedure.
  1732.  
  1733.     Below is some code from pbClock that shows one use of the control track proc:
  1734.  
  1735.         static Boolean    TrackRadioProc(ControlHandle ctl, short part, EventRecord *event)
  1736.         {
  1737.             WindowPtr                window;
  1738.             FileRecHndl                frHndl;
  1739.             TreeObjHndl                root;
  1740.             static ControlActionUPP    cupp;
  1741.         
  1742.             window = (*ctl)->contrlOwner;
  1743.             frHndl = (FileRecHndl)GetWRefCon(window);
  1744.             root   = (*frHndl)->d.doc.root;
  1745.         
  1746.             FetchClockValues(frHndl, 0);
  1747.             mDerefRoot(root)->timeRemaining[0] = mDerefRoot(root)->timeControl[0];
  1748.             mDerefRoot(root)->timeRemaining[1] = mDerefRoot(root)->timeControl[3];
  1749.         
  1750.             if (event->what != mouseDown) return(true);
  1751.         
  1752.             if (!cupp) cupp = (ControlActionUPP)(-1);
  1753.             return(TrackControl(ctl, event->where, cupp));
  1754.         }
  1755.  
  1756.     The reason for the above track procedure is that the radio buttons hold some state information.
  1757.     It is important to know what the old radio button selection was.  When the application calls
  1758.     IsCtlEvent, IsCtlEvent notes that the control clicked on was a radio button, and therefore
  1759.     automatically turns off other radio buttons in the same family.  This means that the old
  1760.     radio button choice is lost to the application.
  1761.  
  1762.     The application could track it, but there's no reason to really.  With the above track proc,
  1763.     the application can make sure that it is called before the old radio button is deselected.
  1764.  
  1765.     The function first determines what document/window is associated with the control.  It then
  1766.     gets the old clock values. FetchClockValues gets the control values, and then stores them based
  1767.     on which radio button is selected.  (Remember that the radio buttons haven't been switched yet.)
  1768.     It then checks the event because this function is called even for keyEquivs.  (To properly
  1769.     emulate a click with a keyPress, this SHOULD be called.)  In the case of a keypress, we return
  1770.     that the control was tracked.  In the case of a mouseDown, we have to determine if it was
  1771.     tracked by calling TrackControl.
  1772. */
  1773.  
  1774.  
  1775.  
  1776. Boolean    ControlKeyEquiv(WindowPtr window, EventRecord *event, ControlHandle *retCtl,
  1777.                         StringPtr defaultEquivs);
  1778. /*
  1779.     ¶ Determine if a keypress is a key equivalent for any control in the window.
  1780.  
  1781.     INPUT:    window                The window whose controls are to be checked for key equivs.
  1782.             event                The keypress event.
  1783.             defaultEquivs        If there is a default button, this string is the set
  1784.                                 of key equivs for it (if it has none of its own).
  1785.     OUTPUT:    retCtl                The control whose criteria for key equivs was met by the event.
  1786.     RESULT:    Boolean                True if a control said it was a key  equiv.
  1787.  
  1788.     When an event is received, if you need to determine if it is a key equivalent for any control
  1789.     in a window, call this.  Normally you don't have to call this, as IsCtlEvent does it for you.
  1790.     However, there is nothing stoppin you from calling it yourself.
  1791. */
  1792.  
  1793.  
  1794.  
  1795. #ifdef __cplusplus
  1796. }
  1797. #endif
  1798.  
  1799. #endif
  1800.